import { Component } from "react";
import { getList } from "../../api/user"
import { Table, Pagination } from "antd"

const columns = [
    {
        title: '名字',
        dataIndex: 'name',
        key: 'name'
    },
    {
        title: '技能',
        dataIndex: 'jineng',
        key: 'jineng'
    },
    {
        title: '理论',
        dataIndex: 'lilun',
        key: 'lilun'
    },
    {
        title: '日期',
        dataIndex: 'date',
        key: 'date'
    },
    {
        title: '操作'
    }
]
class Home extends Component{
    state = {
        page:{
            pageNum:1,
            pageSize:5,
            sumSize:5
        },
        curdata:[]
    }
    getList(){
        getList({...this.state.page}).then(res => {
            // console.log(res);
            this.setState({
                curdata:res.data.listRes,
                sumSize:res.data.pageSize
            })
        })
    }
    componentDidMount(){
        this.getList();
    }
    onChange(pageNum){
        this.setState({
            page:{
                ...this.state.page,
                pageNum
            }
        },() => {
            this.getList();
        })
    }
    render(){
        const {curdata,sumSize,page} = this.state;
        return (
            <div>
                <Table columns={columns} dataSource={curdata} rowKey="id" pagination={false}/>
                <Pagination onChange={this.onChange.bind(this)} defaultCurrent={1} total={sumSize} pageSize={page.pageSize} ></Pagination>
            </div>
        )
    }
}
export default Home;